package d0318;
/*
public class joinTester implements Runnable {
    private String name;
public joinTester(String name){
    this.name=name;
}

    @Override
    public void run() {
     System.out.println(name +"线程开始于:"+ new Date());
    public static void main(String[] args){
       Thread thread1=new Thread(new joinTester(one));
            Thread thread2=new Thread(new joinTester(two));

        }


try{
    Thread.sleep(3000);
}catch (InterruptedException e){
    e.printStackTrace();
}
    System.out.println("主线程结束");
    }
}
*/


import java.util.Date;

class JoinTester implements Runnable {
        private String name;

        public JoinTester(String name){
            this.name=name;
        }

        @Override
        public void run() {
            System.out.println(name+"开始于"+new Date());
            try {
                Thread.sleep(3000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
            System.out.println(name+"结束与"+new Date());


        }

        public static void main(String[] args) {
            //  JoinTester joinTester = new JoinTester("12");
            // joinTester.run();
            Thread thread1 = new Thread(new JoinTester("one"));
            Thread thread2 = new Thread(new JoinTester("two"));
            thread2.start();

            try{
                thread1.join();
                thread2.join();}
            catch (InterruptedException e){
                e.printStackTrace();
            }
            System.out.println("结束");
        }
    }